Interface ResponseInterface

Summary

Fully Qualified Name: CodeIgniter\HTTP\ResponseInterface

Description

Representation of an outgoing, getServer-side response.

Per the HTTP specification, this interface includes properties for each of the following:

Methods

Name Description Defined By
getReason() Gets the response response phrase associated with the status code. ResponseInterface
getStatusCode() Gets the response status code. ResponseInterface
noCache() Sets the appropriate headers to ensure this response is not cached by the browsers. ResponseInterface
send() Sends the output to the browser. ResponseInterface
setCache() A shortcut method that allows the developer to set all of the cache-control headers in one method call. ResponseInterface
setContentType() Sets the Content Type header for this response with the mime type and, optionally, the charset. ResponseInterface
setDate() Sets the date header ResponseInterface
setLastModified() Sets the Last-Modified date header. ResponseInterface
setStatusCode() Return an instance with the specified status code and, optionally, reason phrase. ResponseInterface

Method Details

getReason()

Gets the response response phrase associated with the status code.

Returns: string

getStatusCode()

Gets the response status code.

The status code is a 3-digit integer result code of the getServer's attempt to understand and satisfy the request.

Returns: int Status code.

noCache()

Sets the appropriate headers to ensure this response is not cached by the browsers.

Returns:

send()

Sends the output to the browser.

Returns: \ResponseInterface

setCache()

A shortcut method that allows the developer to set all of the cache-control headers in one method call.

The options array is used to provide the cache-control directives for the header. It might look something like:

 $options = [
     'max-age'  => 300,
     's-maxage' => 900
     'etag'     => 'abcde',
 ];

Typical options are:

Parameter Name Type Description
$options array

Returns: \ResponseInterface

setContentType()

Sets the Content Type header for this response with the mime type and, optionally, the charset.

Parameter Name Type Description
$mime string
$charset string

Returns: \ResponseInterface

setDate()

Sets the date header

Parameter Name Type Description
$date \DateTime

Returns: \ResponseInterface

setLastModified()

Sets the Last-Modified date header.

$date can be either a string representation of the date or, preferably, an instance of DateTime.

Parameter Name Type Description
$date string|\DateTime

Returns:

setStatusCode()

Return an instance with the specified status code and, optionally, reason phrase.

If no reason phrase is specified, will default recommended reason phrase for the response's status code.

Parameter Name Type Description
$code int The
$reason string The

Returns: self

Top